def pickEven(num,block){
    for(i = 2;i<=num;i+=2){
        block(i)
    }
    println()
}
println 'total is $total' //不解析
pickEven(10,{print "$it "}) 
pickEven(10){print "$it "}   //这两种调用闭包的方式一样

def total
total = 0
pickEven(10){a->total+=a}
println "total is $total" //作为GString解析

total = 1;
pickEven(10){a->total*=a}
println "total is $total" //作为GString解析




